home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 1.iso / dist / fw_qt.idb / usr / freeware / include / qdragobject.h.z / qdragobject.h
C/C++ Source or Header  |  2001-04-12  |  6KB  |  236 lines

  1. /****************************************************************************
  2. ** $Id: qt/src/kernel/qdragobject.h   2.3.0   edited 2001-01-26 $
  3. **
  4. ** Definition of QDragObject
  5. **
  6. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  7. **
  8. ** This file is part of the kernel module of the Qt GUI Toolkit.
  9. **
  10. ** This file may be distributed under the terms of the Q Public License
  11. ** as defined by Trolltech AS of Norway and appearing in the file
  12. ** LICENSE.QPL included in the packaging of this file.
  13. **
  14. ** This file may be distributed and/or modified under the terms of the
  15. ** GNU General Public License version 2 as published by the Free Software
  16. ** Foundation and appearing in the file LICENSE.GPL included in the
  17. ** packaging of this file.
  18. **
  19. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  20. ** licenses may use this file in accordance with the Qt Commercial License
  21. ** Agreement provided with the Software.
  22. **
  23. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  24. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  25. **
  26. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  27. **   information about Qt Commercial License Agreements.
  28. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  29. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  30. **
  31. ** Contact info@trolltech.com if any conditions of this licensing are
  32. ** not clear to you.
  33. **
  34. **********************************************************************/
  35.  
  36. #ifndef QDRAGOBJECT_H
  37. #define QDRAGOBJECT_H
  38.  
  39. struct QDragData;
  40. struct QStoredDragData;
  41. class QWidget;
  42.  
  43. #ifndef QT_H
  44. #include "qobject.h"
  45. #include "qimage.h"
  46. #include "qstrlist.h"
  47. #include "qcolor.h"
  48. #endif // QT_H
  49.  
  50. #ifndef QT_NO_MIME
  51.  
  52. class Q_EXPORT QDragObject: public QObject, public QMimeSource {
  53.     Q_OBJECT
  54. public:
  55.     QDragObject( QWidget * dragSource = 0, const char * name = 0 );
  56.     virtual ~QDragObject();
  57.  
  58. #ifndef QT_NO_DRAGANDDROP
  59.     bool drag();
  60.     bool dragMove();
  61.     void dragCopy();
  62.  
  63.     virtual void setPixmap(QPixmap);
  64.     virtual void setPixmap(QPixmap, QPoint hotspot);
  65.     QPixmap pixmap() const;
  66.     QPoint pixmapHotSpot() const;
  67. #endif
  68.  
  69.     QWidget * source();
  70.     static QWidget * target();
  71.  
  72.     static void setTarget(QWidget*);
  73.  
  74. #ifndef QT_NO_DRAGANDDROP
  75.     enum DragMode { DragDefault, DragCopy, DragMove, DragCopyOrMove };
  76.  
  77. protected:
  78.     virtual bool drag(DragMode);
  79. #endif
  80.  
  81. private:
  82.     QDragData * d;
  83. };
  84.  
  85. class Q_EXPORT QStoredDrag: public QDragObject {
  86.     Q_OBJECT
  87.     QStoredDragData * d;
  88.  
  89. public:
  90.     QStoredDrag( const char * mimeType,
  91.          QWidget * dragSource = 0, const char * name = 0 );
  92.     ~QStoredDrag();
  93.  
  94.     virtual void setEncodedData( const QByteArray & );
  95.  
  96.     const char * format(int i) const;
  97.     virtual QByteArray encodedData(const char*) const;
  98. };
  99.  
  100. class QTextDragPrivate;
  101.  
  102. class Q_EXPORT QTextDrag: public QDragObject {
  103.     Q_OBJECT
  104.     QTextDragPrivate* d;
  105. public:
  106.     QTextDrag( const QString &,
  107.            QWidget * dragSource = 0, const char * name = 0 );
  108.     QTextDrag( QWidget * dragSource = 0, const char * name = 0 );
  109.     ~QTextDrag();
  110.  
  111.     virtual void setText( const QString &);
  112.     virtual void setSubtype( const QCString &);
  113.  
  114.     const char * format(int i) const;
  115.     virtual QByteArray encodedData(const char*) const;
  116.  
  117.     static bool canDecode( const QMimeSource* e );
  118.     static bool decode( const QMimeSource* e, QString& s );
  119.     static bool decode( const QMimeSource* e, QString& s, QCString& subtype );
  120. };
  121.  
  122. class QImageDragData;
  123.  
  124. class Q_EXPORT QImageDrag: public QDragObject {
  125.     Q_OBJECT
  126.     QImage img;
  127.     QStrList ofmts;
  128.     QImageDragData* d;
  129.  
  130. public:
  131.     QImageDrag( QImage image,
  132.         QWidget * dragSource = 0, const char * name = 0 );
  133.     QImageDrag( QWidget * dragSource = 0, const char * name = 0 );
  134.     ~QImageDrag();
  135.  
  136.     virtual void setImage( QImage image );
  137.  
  138.     const char * format(int i) const;
  139.     virtual QByteArray encodedData(const char*) const;
  140.  
  141.     static bool canDecode( const QMimeSource* e );
  142.     static bool decode( const QMimeSource* e, QImage& i );
  143.     static bool decode( const QMimeSource* e, QPixmap& i );
  144. };
  145.  
  146.  
  147. class Q_EXPORT QUriDrag: public QStoredDrag {
  148.     Q_OBJECT
  149.  
  150. public:
  151.     QUriDrag( QStrList uris,
  152.         QWidget * dragSource = 0, const char * name = 0 );
  153.     QUriDrag( QWidget * dragSource = 0, const char * name = 0 );
  154.     ~QUriDrag();
  155.  
  156.     void setFilenames( QStringList fnames );
  157.     void setUnicodeUris( QStringList uuris );
  158.     virtual void setUris( QStrList uris );
  159.  
  160.     static QString uriToLocalFile(const char*);
  161.     static QCString localFileToUri(const QString&);
  162.     static QString uriToUnicodeUri(const char*);
  163.     static QCString unicodeUriToUri(const QString&);
  164.     static bool canDecode( const QMimeSource* e );
  165.     static bool decode( const QMimeSource* e, QStrList& i );
  166.     static bool decodeToUnicodeUris( const QMimeSource* e, QStringList& i );
  167.     static bool decodeLocalFiles( const QMimeSource* e, QStringList& i );
  168. };
  169.  
  170. class Q_EXPORT QColorDrag : public QStoredDrag
  171. {
  172.     Q_OBJECT
  173.     QColor color;
  174.  
  175. public:
  176.     QColorDrag( const QColor &col, QWidget *dragsource = 0, const char *name = 0 );
  177.     QColorDrag( QWidget * dragSource = 0, const char * name = 0 );
  178.     void setColor( const QColor &col );
  179.  
  180.     static bool canDecode( QMimeSource * );
  181.     static bool decode( QMimeSource *, QColor &col );
  182. };
  183.  
  184. #ifndef QT_NO_COMPAT
  185. typedef QUriDrag QUrlDrag;
  186. #endif
  187.  
  188. #ifndef QT_NO_DRAGANDDROP
  189.  
  190. // QDragManager is not part of the public API.  It is defined in a
  191. // header file simply so different .cpp files can implement different
  192. // member functions.
  193. //
  194.  
  195. class Q_EXPORT QDragManager: public QObject {
  196.     Q_OBJECT
  197.  
  198. private:
  199.     QDragManager();
  200.     ~QDragManager();
  201.     // only friend classes can use QDragManager.
  202.     friend class QDragObject;
  203.     friend class QDragMoveEvent;
  204.     friend class QDropEvent;
  205.  
  206.     bool eventFilter( QObject *, QEvent * );
  207.     void timerEvent( QTimerEvent* );
  208.  
  209.     bool drag( QDragObject *, QDragObject::DragMode );
  210.  
  211.     void cancel( bool deleteSource = TRUE );
  212.     void move( const QPoint & );
  213.     void drop();
  214.     void updatePixmap();
  215.  
  216. private:
  217.     QDragObject * object;
  218.     void updateMode( ButtonState newstate );
  219.     void updateCursor();
  220.  
  221.     QWidget * dragSource;
  222.     QWidget * dropWidget;
  223.     bool beingCancelled;
  224.     bool restoreCursor;
  225.     bool willDrop;
  226.  
  227.     QPixmap *pm_cursor;
  228.     int n_cursor;
  229. };
  230.  
  231. #endif
  232.  
  233. #endif // QT_NO_MIME
  234.  
  235. #endif // QDRAGOBJECT_H
  236.